package org.micode.demo.web.service;

import lombok.extern.slf4j.Slf4j;
import org.micode.common.domain.DataPage;
import org.micode.common.domain.vo.EditObjVO;
import org.micode.common.domain.vo.KeyVO;
import org.micode.common.helper.MethodHelper;
import org.micode.demo.db.domain.dto.SysUserExtDTO;
import org.micode.demo.db.domain.query.SysUserExtQuery;
import org.micode.demo.db.service.DaoSysUserExtService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 系统用户扩展表，关联型(sys_user_ext) 的APP服务实现类
 * <p>
 *
 * @author: wutianbin
 */
@Service
@Slf4j
public class SysUserExtService {

    @Autowired
    private DaoSysUserExtService daoSysUserExtService;

    public DataPage<SysUserExtDTO> list(SysUserExtQuery dataQuery) {
        return MethodHelper.invoke(daoSysUserExtService::listPage, dataQuery);
    }

    public SysUserExtDTO info(KeyVO<Long> id) {
        return MethodHelper.invoke(daoSysUserExtService::get, id.getKey());
    }

    public SysUserExtDTO insert(SysUserExtDTO sysUserExt) {
        return MethodHelper.invoke(daoSysUserExtService::insert, sysUserExt);
    }

    public Integer update(SysUserExtDTO sysUserExt) {
        return MethodHelper.invoke(daoSysUserExtService::update, sysUserExt);
    }

    public Integer delete(EditObjVO<List<Long>> delIds) {
        return daoSysUserExtService.deleteByKeys(delIds);
    }

    public SysUserExtDTO getInfoByUserId(Long userId) {
        SysUserExtDTO dto = new SysUserExtDTO();
        dto.setUserId(userId);
        return daoSysUserExtService.getOne(dto);
    }

}
